package com.html;


import com.html.dto.ElementDTO;
import com.html.dto.URLElementMap;
import com.html.utils.HTMLUtil;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Attribute;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Node;
import org.springframework.util.CollectionUtils;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @ClassName: HTMLTest
 * @Author: Jack.Zhang
 * @Description:
 * @Date: 2021-09-27
 */
public class HTMLTest {
    public static void main(String[] args) throws Exception {
        final URLElementMap urlElementMap = HTMLUtil.getURLElementMap("https://www.cnblogs.com/zyzl/p/4526914.html");
        if (Objects.nonNull(urlElementMap)) {
            final Map<String, String> attributeMap = urlElementMap.getElementList().stream().flatMap(v -> v.getParamsMap().entrySet().stream())
                    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (k1, k2) -> k2));
//            System.out.println(attributeMap);
        }
//        System.out.println(urlElementMap);
    }


}
